#!/usr/bin/env python3
"""
创建MySQL数据库
"""

import pymysql

def create_database():
    try:
        # 连接到MySQL服务器（不指定数据库）
        connection = pymysql.connect(
            host='47.115.144.218',
            user='root',
            password='clannad123',
            port=3306
        )
        
        cursor = connection.cursor()
        
        # 创建数据库
        cursor.execute("CREATE DATABASE IF NOT EXISTS houseDB")
        print("✅ 数据库 'houseDB' 创建成功")
        
        # 查看所有数据库
        cursor.execute("SHOW DATABASES")
        databases = cursor.fetchall()
        print("📋 现有数据库:")
        for db in databases:
            print(f"  - {db[0]}")
        
        cursor.close()
        connection.close()
        
    except Exception as e:
        print(f"❌ 创建数据库失败: {e}")

if __name__ == "__main__":
    create_database()
